#include <bits/stdc++.h>
using namespace std;
template <typename T>
void readi(T &x)
{
    T f = 1;
    x = 0;
    int ch;
    while (ch = getchar(), !feof(stdin) && !isdigit(ch) && ch != '-')
        ;
    if (ch == '-')
        f = -f, ch = getchar();
    while (!feof(stdin) && isdigit(ch))
    {
        x = (x << 3) + (x << 1) + ch - 0x30;
        ch = getchar();
    }
    x *= f;
}
template <typename T>
void writei(T x)
{
    if (x == 0)
    {
        putchar('0');
        return;
    }
    if (x < 0)
        x = -x, putchar('-');
    T p = 1;
    while (x / p >= 10)
        p = (p << 3) + (p << 1);
    while (p)
    {
        putchar(x / p + 0x30);
        x %= p;
        p /= 10;
    }
}
const int MAXN = 2e5 + 7;
int A[MAXN], n;
void solve()
{
    readi(n);
    for (int i = 0; i < n; i++)
        readi(A[i]);
    unsigned long long Ans = 0;
    for (unsigned long long i = 0; i < (1llu << n); i++)
    {
        int last0 = 0, last1 = 0;
        unsigned long long C = 0;
        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                if (A[j] == last1)
                    C += A[j];
                last1 = A[j];
            }
            else
            {
                if (A[j] == last0)
                    C += A[j];
                last0 = A[j];
            }
        }
        Ans = max(Ans, C);
    }
    writei(Ans);
    putchar('\n');
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int T;
    readi(T);
    while (T--)
        solve();
    return 0;
}